﻿#include "../Inc/data_public.h"
#include "../Inc/disp_alarm.h"
//#include "../Inc/keyboard.h"
/* 选项卡框架 */
static lv_timer_t* timer_refresh_alarm;
static ta_userData_t taUser_alarm[11];	  // 输入框

static lv_obj_t* tempAlarmSideBtn;		  // 侧边栏按钮
static lv_obj_t* flowAlarmSideBtn;
static lv_obj_t* pressAlarmSideBtn;
static lv_obj_t* waterAlarmSideBtn;
static lv_obj_t* remainAlarmSideBtn;
static lv_obj_t* otherAlarmSideBtn;
static lv_obj_t* tabCont;			  // 主显示容器
static lv_obj_t* tabList;			  // 侧边栏容器
static lv_style_t tab_btn_style;	  // 侧边栏按钮样式
static lv_style_t tab_bg_style;       // 主容器背景样式
/* 选项卡一 */
static lv_obj_t* runModeBtn;           // 检测模式运行按钮
static lv_obj_t* elecModeBtn;          // 检测模式上电按钮
static lv_obj_t* closeModeBtn;         // 检测模式关闭按钮
static lv_obj_t* alarmUpBtn;           // 上限报警按钮
static lv_obj_t* malfuncUpBtn;         // 上限故障按钮
static lv_obj_t* closeUpBtn;           // 上限关闭按钮
static lv_obj_t* alarmDownBtn;         // 下限报警按钮
static lv_obj_t* malfuncDownBtn;       // 下限故障按钮
static lv_obj_t* closeDownBtn;         // 下限关闭按钮

/* 选项卡二 */
static lv_obj_t* alarmLevelBtn;           // 报警级别按钮
static lv_obj_t* malfLevelBtn;            // 故障级别按钮
static lv_obj_t* closeLevelBtn;           // 关闭报警级别按钮
static lv_obj_t* sensorAlarmBtn;          // 传感器报警按钮
static lv_obj_t* sensorMalfBtn;           // 传感器故障按钮
static lv_obj_t* sensorCloseBtn;          // 传感器关闭按钮

/* 选项卡三 */
static lv_obj_t* pressAlarmBtn;           // 压力报警级别按钮
static lv_obj_t* pressMalfBtn;            // 压力故障级别按钮
static lv_obj_t* pressCloseBtn;           // 关闭压力报警级别按钮
static lv_obj_t* pressSensorAlarmBtn;          // 压力传感器报警按钮
static lv_obj_t* pressSensorMalfBtn;           // 压力传感器故障按钮
static lv_obj_t* pressCensorCloseBtn;          // 压力传感器关闭按钮

/* 选项卡四 */
static lv_obj_t* waterAlarmBtn;                // 水质报警级别按钮
static lv_obj_t* waterCloseBtn;                // 关闭水质报警级别按钮

/* 选项卡五 */
static lv_obj_t* remainAlarmBtn;                // 维护报警级别按钮
static lv_obj_t* remainCloseBtn;                // 关闭维护报警级别按钮
static lv_obj_t* pumpResetBtn;                  // 循环泵复位按钮
static lv_obj_t* compressResetBtn;              // 压缩机复位按钮
static lv_obj_t* filterResetBtn;                // 过滤器复位按钮
static lv_obj_t* compress2ResetBtn;             // 压缩机二复位按钮

/* 选项卡六 */
static lv_obj_t* leakAlarmBtn;                 // 泄露报警级别按钮
static lv_obj_t* leakCloseBtn;                 // 关闭泄露报警级别按钮
static lv_obj_t* leakMalfBtn;                  // 泄露故障级别按钮
static char * Unit;
/* 通讯数据库 */
uint8_t alarmTabView = 0;				    // 当前选项卡： 0：选项卡一、 1：选项卡二、 2：选项卡三

/* 刷新输入框范围*/
static void refresh_tempAlarm_txra(void)
{
	taUser_alarm[0].data.userData.value = &UP.FLT_HL_Temp1;     // 保护上限
	taUser_alarm[0].data.userData.store_enable = 1;
	taUser_alarm[0].data.min = UP.FLT_LL_Temp1;	       // 报警_保护温度下限
	taUser_alarm[0].data.max = FP.HL_TempFF;		   // 工厂_保护温度上限
	taUser_alarm[1].data.userData.value= &UP.FLT_LL_Temp1;	   // 保护下限
	taUser_alarm[1].data.userData.store_enable = 1;
	taUser_alarm[1].data.min = FP.LL_TempFF;	       // 工厂_保护温度下限
	taUser_alarm[1].data.max = UP.FLT_HL_Temp1;	       // 报警_保护温度上限
	taUser_alarm[2].data.userData.value = &UP.Alarm_HL_Temp1;   // 报警上限
	taUser_alarm[2].data.userData.store_enable = 1;
	taUser_alarm[2].data.min = UP.FLT_LL_Temp1;	       // 报警_保护温度下限
	taUser_alarm[2].data.max = UP.FLT_HL_Temp1;	       // 报警_保护温度上限
	taUser_alarm[3].data.userData.value = &UP.Alarm_LL_Temp1;   // 报警下限
	taUser_alarm[3].data.userData.store_enable = 1;
	taUser_alarm[3].data.min = FP.LL_TempFF;	       // 工厂_保护温度下限
	taUser_alarm[3].data.max = UP.FLT_HL_Temp1;	       // 报警_报警温度上限
}

static void tab_alarm_init(void)
{
	taUser_alarm[0].data.userData.value = &UP.FLT_HL_Temp1;     // 保护上限
	taUser_alarm[0].data.userData.store_enable = 1;
	taUser_alarm[0].data.min = UP.FLT_LL_Temp1;	       // 报警_保护温度下限
	taUser_alarm[0].data.max = FP.HL_TempFF;		   // 工厂_保护温度上限
	taUser_alarm[1].data.userData.value= &UP.FLT_LL_Temp1;	   // 保护下限
	taUser_alarm[1].data.userData.store_enable = 1;
	taUser_alarm[1].data.min = FP.LL_TempFF;	       // 工厂_保护温度下限
	taUser_alarm[1].data.max = UP.FLT_HL_Temp1;	       // 报警_保护温度上限
	taUser_alarm[2].data.userData.value = &UP.Alarm_HL_Temp1;   // 报警上限
	taUser_alarm[2].data.userData.store_enable = 1;
	taUser_alarm[2].data.min = UP.FLT_LL_Temp1;	       // 报警_保护温度下限
	taUser_alarm[2].data.max = UP.FLT_HL_Temp1;	       // 报警_保护温度上限
	taUser_alarm[3].data.userData.value = &UP.Alarm_LL_Temp1;   // 报警下限
	taUser_alarm[3].data.userData.store_enable = 1;
	taUser_alarm[3].data.min = FP.LL_TempFF;	       // 工厂_保护温度下限
	taUser_alarm[3].data.max = UP.FLT_HL_Temp1;	       // 报警_报警温度上限
	taUser_alarm[4].data.userData.value = &UP.Alarm_LL_Flow;	   // 流量下限
	taUser_alarm[4].data.userData.store_enable = 1;
	taUser_alarm[4].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[4].data.max = 999;	       // 键盘输入最大值
	taUser_alarm[5].data.userData.value = &UP.Alarm_HL_Press;   // 压力上限
	taUser_alarm[5].data.userData.store_enable = 1;
	taUser_alarm[5].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[5].data.max = 999;	       // 键盘输入最大值
	taUser_alarm[6].data.userData.value = &UP.Alarm_LL_Press;   // 压力下限
	taUser_alarm[6].data.userData.store_enable = 1;
	taUser_alarm[6].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[6].data.max = 999;	       // 键盘输入最大值
	taUser_alarm[7].data.userData.value = &UP.Alarm_LL_DI;	   // 水质报警数值
	taUser_alarm[7].data.userData.store_enable = 1;
	taUser_alarm[7].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[7].data.max = 99;	       // 键盘输入最大值
	taUser_alarm[8].data.userData.value = &FP.LL_TempSV1;	   // 水质控制范围下限
	taUser_alarm[8].data.userData.store_enable = 1;
	taUser_alarm[8].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[8].data.max = 99;	       // 键盘输入最大值
	taUser_alarm[9].data.userData.value = &FP.HL_TempSV1;	   // 水质控制范围上限
	taUser_alarm[9].data.userData.store_enable = 1;
	taUser_alarm[9].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[9].data.max = 99;	       // 键盘输入最大值
	taUser_alarm[10].data.userData.value = &UP.CycleTime_Filter;   // 过滤器设定值
	taUser_alarm[10].data.userData.store_enable = 1;
	taUser_alarm[10].data.min = 0;	       // 键盘输入最小值
	taUser_alarm[10].data.max = 9999;	       // 键盘输入最大值

	for (uint8_t i = 0; i < 11; i++)
	{
		taUser_alarm[i].width = lv_pct(19);
		taUser_alarm[i].height = lv_pct(10);
		taUser_alarm[i].max_length = 6;
		taUser_alarm[i].accepted_chars = "0123456789-.";
		taUser_alarm[i].one_line = true;
		taUser_alarm[i].type = "%.1f";
	}
	taUser_alarm[10].type = "%d";
	taUser_alarm[0].pos_x = lv_pct(76);
	taUser_alarm[0].pos_y = lv_pct(25);

	taUser_alarm[1].pos_x = lv_pct(76);
	taUser_alarm[1].pos_y = lv_pct(54);

	taUser_alarm[2].pos_x = lv_pct(76);
	taUser_alarm[2].pos_y = lv_pct(83);

	taUser_alarm[3].pos_x = lv_pct(76);
	taUser_alarm[3].pos_y = lv_pct(112);

	taUser_alarm[4].pos_x = lv_pct(55);
	taUser_alarm[4].pos_y = lv_pct(25);


	taUser_alarm[5].pos_x = lv_pct(53);
	taUser_alarm[5].pos_y = lv_pct(25);
	taUser_alarm[5].width = lv_pct(20);

	taUser_alarm[6].pos_x = lv_pct(53);
	taUser_alarm[6].pos_y = lv_pct(54);
	taUser_alarm[6].width = lv_pct(20);

	taUser_alarm[7].pos_x = lv_pct(55);
	taUser_alarm[7].pos_y = lv_pct(51);

	taUser_alarm[8].pos_x = lv_pct(29);
	taUser_alarm[8].pos_y = lv_pct(79);

	taUser_alarm[9].pos_x = lv_pct(55);
	taUser_alarm[9].pos_y = lv_pct(79);

	taUser_alarm[10].pos_x = lv_pct(55);
	taUser_alarm[10].pos_y = lv_pct(82);

}
static void refresh_alarm_cb(lv_timer_t* timer)
{
	LV_UNUSED(timer);
	/* 遍历屏幕的父对象的所有子对象 */
	for(uint8_t i = 0; i < lv_obj_get_child_cnt(tabCont); i++)
	{
		lv_obj_t* child = lv_obj_get_child(tabCont, i);
		/* 遍历所有输入框子对象 */
		if(lv_obj_check_type(child, &lv_textarea_class))
		{
			char str[10] = {0};
			ta_userData_t userData = *(ta_userData_t *)lv_obj_get_user_data(child);
			if(type_is_float(userData.type))
			{
				sprintf(str, userData.type, *(float*)userData.data.userData.value);
			}
			else
			{
				sprintf(str, userData.type, *(uint16_t*)userData.data.userData.value);
			}

			lv_textarea_set_text(child, str);
			/* 重新报警输入框范围 */
			refresh_tempAlarm_txra();
		}

	}

}
/**
  * @brief	用于处理温度报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_tempAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
	lv_obj_t* target = lv_event_get_target(e);
	if (code == LV_EVENT_CLICKED)
	{
	    /* 检测模式回调 */
		if (target == runModeBtn && UP.AlarmType_Temp != 0)
		{
			lv_obj_add_state(runModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(elecModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeModeBtn, LV_STATE_CHECKED);
	        UP.AlarmType_Temp = 0;
	        send_aux(&UP.AlarmType_Temp);
		}
		else if (target == elecModeBtn && UP.AlarmType_Temp != 1)
		{
			lv_obj_add_state(elecModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(runModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeModeBtn, LV_STATE_CHECKED);
	        UP.AlarmType_Temp = 1;
	        send_aux(&UP.AlarmType_Temp);
		}
		else if (target == closeModeBtn && UP.AlarmType_Temp != 2)
		{
			lv_obj_add_state(closeModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(runModeBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(elecModeBtn, LV_STATE_CHECKED);
	        UP.AlarmType_Temp = 2;
	        send_aux(&UP.AlarmType_Temp);
		}
		/* 保护上限回调 */
		if (target == alarmUpBtn && UP.AlarmType_TempHL != 0)
		{
			lv_obj_add_state(alarmUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfuncUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeUpBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempHL = 0;
	        send_aux(&UP.AlarmType_TempHL);
		}
		else if (target == malfuncUpBtn && UP.AlarmType_TempHL != 1)
		{
			lv_obj_add_state(malfuncUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeUpBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempHL = 1;
	        send_aux(&UP.AlarmType_TempHL);
		}
		else if (target == closeUpBtn && UP.AlarmType_TempHL != 2)
		{
			lv_obj_add_state(closeUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmUpBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfuncUpBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempHL = 2;
	        send_aux(&UP.AlarmType_TempHL);
		}
		/* 保护下限回调 */
		if (target == alarmDownBtn && UP.AlarmType_TempLL != 0)
		{
			lv_obj_add_state(alarmDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfuncDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeDownBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempLL = 0;
	        send_aux(&UP.AlarmType_TempLL);
		}
		else if (target == malfuncDownBtn && UP.AlarmType_TempLL != 1)
		{
			lv_obj_add_state(malfuncDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeDownBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempLL = 1;
	        send_aux(&UP.AlarmType_TempLL);
		}
		else if (target == closeDownBtn && UP.AlarmType_TempLL != 2)
		{
			lv_obj_add_state(closeDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmDownBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfuncDownBtn, LV_STATE_CHECKED);
	        UP.AlarmType_TempLL = 2;
	        send_aux(&UP.AlarmType_TempLL);
		}
	}
}
/**
  * @brief	用于创建温度报警主容器
  * @param  None
  * @retval None
  */
static void tab_tempAlarm_create(void)
{
	/* 检测模式 */
	lv_obj_t* label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].modeTest);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

    runModeBtn = lv_btn_create(tabCont);
    lv_obj_add_style(runModeBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(runModeBtn, 90, LV_STATE_DEFAULT);
    lv_obj_align_to(runModeBtn, label, LV_ALIGN_OUT_RIGHT_MID, -25, 0);
    lv_obj_t*lable = lv_label_create(runModeBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].running);
    lv_obj_set_style_bg_color(runModeBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);

    lv_obj_align_to(lable, runModeBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(runModeBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    elecModeBtn = lv_btn_create(tabCont);
    lv_obj_add_style(elecModeBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(elecModeBtn, 90, LV_STATE_DEFAULT);
    lv_obj_align_to(elecModeBtn, runModeBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(elecModeBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].power);
    lv_obj_set_style_bg_color(elecModeBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, elecModeBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(elecModeBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    closeModeBtn = lv_btn_create(tabCont);
    lv_obj_add_style(closeModeBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(closeModeBtn, 90, LV_STATE_DEFAULT);
    lv_obj_align_to(closeModeBtn, elecModeBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(closeModeBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(closeModeBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, closeModeBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(closeModeBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 保护上限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].upper);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 94);

    alarmUpBtn = lv_btn_create(tabCont);
    lv_obj_add_style(alarmUpBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(alarmUpBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(alarmUpBtn, label, LV_ALIGN_OUT_RIGHT_MID, -25, 0);
    lable = lv_label_create(alarmUpBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);  //文本内容
    lv_obj_set_style_bg_color(alarmUpBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, alarmUpBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(alarmUpBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    malfuncUpBtn = lv_btn_create(tabCont);
    lv_obj_add_style(malfuncUpBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(malfuncUpBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(malfuncUpBtn, alarmUpBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(malfuncUpBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);  //文本内容
    lv_obj_set_style_bg_color(malfuncUpBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, malfuncUpBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(malfuncUpBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    closeUpBtn = lv_btn_create(tabCont);
    lv_obj_add_style(closeUpBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(closeUpBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(closeUpBtn, malfuncUpBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(closeUpBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);  //文本内容
    lv_obj_set_style_bg_color(closeUpBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, closeUpBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(closeUpBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    if (UP.Unit_Temp == 0)
    {
    	Unit = "℃";
    }
    else
    {
    	Unit = "℉";
    }
	label = lv_label_create(tabCont);
	lv_label_set_text(label, Unit);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(3));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(97), lv_pct(31));
    /* 保护下限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].lowest);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 188);

    alarmDownBtn = lv_btn_create(tabCont);
    lv_obj_add_style(alarmDownBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(alarmDownBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(alarmDownBtn, label, LV_ALIGN_OUT_RIGHT_MID, -25, 0);
    lable = lv_label_create(alarmDownBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);  //文本内容
    lv_obj_set_style_bg_color(alarmDownBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, alarmDownBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(alarmDownBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    malfuncDownBtn = lv_btn_create(tabCont);
    lv_obj_add_style(malfuncDownBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(malfuncDownBtn, 80, LV_STATE_DEFAULT);  //宽
    lable = lv_label_create(malfuncDownBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
    lv_obj_set_style_bg_color(malfuncDownBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, malfuncDownBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_align_to(malfuncDownBtn, alarmDownBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lv_obj_add_event_cb(malfuncDownBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    closeDownBtn = lv_btn_create(tabCont);
    lv_obj_add_style(closeDownBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(closeDownBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(closeDownBtn, malfuncDownBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(closeDownBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(closeDownBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, closeDownBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(closeDownBtn, tab_tempAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	label = lv_label_create(tabCont);
	lv_label_set_text(label, Unit);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(3));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(97), lv_pct(58));
    /* 报警上限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].alarmUpper);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(35));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 282);

	label = lv_label_create(tabCont);
	lv_label_set_text(label, Unit);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(3));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(97), lv_pct(87));

	/* 报警下限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].alarmLower);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(35));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 376);

	label = lv_label_create(tabCont);
	lv_label_set_text(label, Unit);
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(3));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(97), lv_pct(116));
	for(uint8_t i = 0; i < 4; i++)
	{
		textarea_create_by(tabCont, &taUser_alarm[i]);
	}
    /* 根据主板标志位判断按钮状态 */
	/* check mode btn*/
	if (UP.AlarmType_Temp == 0)
	{
		lv_obj_add_state(runModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(elecModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeModeBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_Temp == 1)
	{
		lv_obj_add_state(elecModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(runModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeModeBtn, LV_STATE_CHECKED);

	}
	else if (UP.AlarmType_Temp == 2)
	{
		lv_obj_add_state(closeModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(runModeBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(elecModeBtn, LV_STATE_CHECKED);

	}
	/* protect  up btn */
	if (UP.AlarmType_TempHL == 0)
	{
		lv_obj_add_state(alarmUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfuncUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeUpBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_TempHL == 1)
	{
		lv_obj_add_state(malfuncUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeUpBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_TempHL == 2)
	{
		lv_obj_add_state(closeUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmUpBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfuncUpBtn, LV_STATE_CHECKED);
	}
	/* protect down btn */
	if (UP.AlarmType_TempLL == 0)
	{
		lv_obj_add_state(alarmDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfuncDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeDownBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_TempLL == 1)
	{
		lv_obj_add_state(malfuncDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeDownBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_TempLL == 2)
	{
		lv_obj_add_state(closeDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmDownBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfuncDownBtn, LV_STATE_CHECKED);
	}
}

/**
  * @brief	用于处理流量报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_flowAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
	lv_obj_t* target = lv_event_get_target(e);
	if (code == LV_EVENT_CLICKED)
	{

	    if (target == alarmLevelBtn)
	    {
	    	UP.AlarmType_FlowLL = 0;
	    	send_aux(&UP.AlarmType_FlowLL);
			lv_obj_add_state(alarmLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeLevelBtn, LV_STATE_CHECKED);
	    }
	    else if (target == malfLevelBtn)
	    {
	    	UP.AlarmType_FlowLL = 1;
	    	send_aux(&UP.AlarmType_FlowLL);
			lv_obj_add_state(malfLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(closeLevelBtn, LV_STATE_CHECKED);
	    }

	    else if (target == closeLevelBtn)
	    {
	    	UP.AlarmType_FlowLL = 2;
	    	send_aux(&UP.AlarmType_FlowLL);
			lv_obj_add_state(closeLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(alarmLevelBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(malfLevelBtn, LV_STATE_CHECKED);
	    }
	    else if (target == sensorAlarmBtn)
	    {
	    	UP.AlarmType_FlowSensor = 0;
	    	send_aux(&UP.AlarmType_FlowSensor);
			lv_obj_add_state(sensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorCloseBtn, LV_STATE_CHECKED);
	    }
	    /* 检测模式回调 */
	    else if (target == sensorMalfBtn)
		{
	    	UP.AlarmType_FlowSensor = 1;
	    	send_aux(&UP.AlarmType_FlowSensor);
			lv_obj_add_state(sensorMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorCloseBtn, LV_STATE_CHECKED);
		}
		else if (target == sensorCloseBtn)
		{
			UP.AlarmType_FlowSensor = 2;
			send_aux(&UP.AlarmType_FlowSensor);
			lv_obj_add_state(sensorCloseBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(sensorMalfBtn, LV_STATE_CHECKED);
		}
	}
}
/**
  * @brief	用于创建流量报警主容器
  * @param  None
  * @retval None
  */
static void tab_flowAlarm_create(void)
{
	/* 报警级别 */
	lv_obj_t* label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].AlarmLevel);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

	alarmLevelBtn = lv_btn_create(tabCont);
    lv_obj_add_style(alarmLevelBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(alarmLevelBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(alarmLevelBtn, label, LV_ALIGN_OUT_RIGHT_MID, 50, 0);
    lv_obj_t*lable = lv_label_create(alarmLevelBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);
    lv_obj_set_style_bg_color(alarmLevelBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, alarmLevelBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(alarmLevelBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    malfLevelBtn = lv_btn_create(tabCont);
    lv_obj_add_style(malfLevelBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(malfLevelBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(malfLevelBtn, alarmLevelBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(malfLevelBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
    lv_obj_set_style_bg_color(malfLevelBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, malfLevelBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(malfLevelBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    closeLevelBtn = lv_btn_create(tabCont);
    lv_obj_add_style(closeLevelBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(closeLevelBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(closeLevelBtn, malfLevelBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(closeLevelBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(closeLevelBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, closeLevelBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(closeLevelBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 流量下限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].flowDown);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(40));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 94);

	label = lv_label_create(tabCont);
	lv_label_set_text(label, "THP");
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(15));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(75), 94);
    /* 传感器异常 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].sensorErr);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(35));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 188);

	sensorAlarmBtn = lv_btn_create(tabCont);
    lv_obj_add_style(sensorAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(sensorAlarmBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(sensorAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
    lable = lv_label_create(sensorAlarmBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);  //文本内容
    lv_obj_set_style_bg_color(sensorAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, sensorAlarmBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(sensorAlarmBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    sensorMalfBtn = lv_btn_create(tabCont);
    lv_obj_add_style(sensorMalfBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(sensorMalfBtn, 80, LV_STATE_DEFAULT);  //宽
    lable = lv_label_create(sensorMalfBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
    lv_obj_set_style_bg_color(sensorMalfBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, sensorMalfBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_align_to(sensorMalfBtn, sensorAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lv_obj_add_event_cb(sensorMalfBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    sensorCloseBtn = lv_btn_create(tabCont);
    lv_obj_add_style(sensorCloseBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(sensorCloseBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(sensorCloseBtn, sensorMalfBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(sensorCloseBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(sensorCloseBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, sensorCloseBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(sensorCloseBtn, tab_flowAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	textarea_create_by(tabCont, &taUser_alarm[4]);

    /* 根据主板标志位判断按钮状态 */
	/* check mode btn*/
	if (UP.AlarmType_FlowLL == 0)
	{
		lv_obj_add_state(alarmLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeLevelBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_FlowLL == 1)
	{
		lv_obj_add_state(malfLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(closeModeBtn, LV_STATE_CHECKED);

	}
	else if (UP.AlarmType_FlowLL == 2)
	{
		lv_obj_add_state(closeLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(alarmLevelBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(malfLevelBtn, LV_STATE_CHECKED);

	}
	/* protect  up btn */
	if (UP.AlarmType_FlowSensor == 0)
	{
		lv_obj_add_state(sensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorCloseBtn, LV_STATE_CHECKED);

	}
	else if (UP.AlarmType_FlowSensor == 1)
	{
		lv_obj_add_state(sensorMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_FlowSensor == 2)
	{
		lv_obj_add_state(sensorCloseBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(sensorMalfBtn, LV_STATE_CHECKED);
	}

}

/**
  * @brief	用于处理压力报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_pressAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
	lv_obj_t* target = lv_event_get_target(e);
	if (code == LV_EVENT_CLICKED)
	{

	    if (target == pressAlarmBtn)
	    {
	    	UP.AlarmType_PressHL = 0;
	    	send_aux(&UP.AlarmType_PressHL);
			lv_obj_add_state(pressAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressCloseBtn, LV_STATE_CHECKED);
	    }
	    else if (target == pressMalfBtn)
	    {
	    	UP.AlarmType_PressHL = 1;
	    	send_aux(&UP.AlarmType_PressHL);
			lv_obj_add_state(pressMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressCloseBtn, LV_STATE_CHECKED);
	    }

	    else if (target == pressCloseBtn)
	    {
	    	UP.AlarmType_PressHL = 2;
	    	send_aux(&UP.AlarmType_PressHL);
			lv_obj_add_state(pressCloseBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressMalfBtn, LV_STATE_CHECKED);
	    }
	    else if (target == pressSensorAlarmBtn)
	    {
	    	UP.AlarmType_OutPressSensor = 0;
	    	send_aux(&UP.AlarmType_OutPressSensor);
			lv_obj_add_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressSensorMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressCensorCloseBtn, LV_STATE_CHECKED);
	    }
	    /* 检测模式回调 */
	    else if (target == pressSensorMalfBtn)
		{
	    	UP.AlarmType_OutPressSensor = 1;
	    	send_aux(&UP.AlarmType_OutPressSensor);
			lv_obj_add_state(pressSensorMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressCensorCloseBtn, LV_STATE_CHECKED);
		}
		else if (target == pressCensorCloseBtn)
		{
			UP.AlarmType_OutPressSensor = 2;
			send_aux(&UP.AlarmType_OutPressSensor);
			lv_obj_add_state(pressCensorCloseBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(pressSensorMalfBtn, LV_STATE_CHECKED);
		}
	}
}
/**
  * @brief	用于创建压力报警主容器
  * @param  None
  * @retval None
  */
static void tab_pressAlarm_create(void)
{
	/* 报警级别 */
	lv_obj_t* label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].AlarmLevel);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

	pressAlarmBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressAlarmBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(pressAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 50, 0);
    lv_obj_t*lable = lv_label_create(pressAlarmBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);
    lv_obj_set_style_bg_color(pressAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressAlarmBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pressAlarmBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    pressMalfBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressMalfBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressMalfBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(pressMalfBtn, pressAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(pressMalfBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
    lv_obj_set_style_bg_color(pressMalfBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressMalfBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pressMalfBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    pressCloseBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressCloseBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressCloseBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(pressCloseBtn, pressMalfBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(pressCloseBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(pressCloseBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressCloseBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pressCloseBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 报警上限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].alarmUp);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 94);

    /* 报警下限 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].alarmDown);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 188);

	for (uint8_t i = 1; i <= 2; i++)
	{
		label = lv_label_create(tabCont);
		lv_label_set_text(label, "psi");
		lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
		lv_obj_set_width(label, lv_pct(10));
		lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(75), 94 * i);
	}

    /* 传感器异常 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].sensorErr);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(35));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 282);

	pressSensorAlarmBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressSensorAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressSensorAlarmBtn, 80, LV_STATE_DEFAULT);  //宽
    lv_obj_align_to(pressSensorAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
    lable = lv_label_create(pressSensorAlarmBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);  //文本内容
    lv_obj_set_style_bg_color(pressSensorAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressSensorAlarmBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pressSensorAlarmBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    pressSensorMalfBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressSensorMalfBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressSensorMalfBtn, 80, LV_STATE_DEFAULT);  //宽
    lable = lv_label_create(pressSensorMalfBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
    lv_obj_set_style_bg_color(pressSensorMalfBtn, lv_color_hex(0x00CC33), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressSensorMalfBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_align_to(pressSensorMalfBtn, pressSensorAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lv_obj_add_event_cb(pressSensorMalfBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    pressCensorCloseBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pressCensorCloseBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pressCensorCloseBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(pressCensorCloseBtn, pressSensorMalfBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(pressCensorCloseBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(pressCensorCloseBtn, lv_color_hex(0x00CC33), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pressCensorCloseBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pressCensorCloseBtn, tab_pressAlarm_event_cb, LV_EVENT_CLICKED, NULL);
	for(uint8_t i = 5; i < 7; i++)
	{
		textarea_create_by(tabCont, &taUser_alarm[i]);
	}
    /* 根据主板标志位判断按钮状态 */
	/* check mode btn*/
	if (UP.AlarmType_PressHL == 0)
	{
		lv_obj_add_state(pressAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_PressHL == 1)
	{
		lv_obj_add_state(pressMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressCloseBtn, LV_STATE_CHECKED);

	}
	else if (UP.AlarmType_PressHL == 2)
	{
		lv_obj_add_state(pressMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressCloseBtn, LV_STATE_CHECKED);
	}
	/* protect  up btn */
	if (UP.AlarmType_OutPressSensor == 0)
	{
		lv_obj_add_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressSensorMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressCensorCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_OutPressSensor == 1)
	{
		lv_obj_add_state(pressSensorMalfBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressCensorCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_OutPressSensor == 2)
	{
		lv_obj_add_state(pressCensorCloseBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressSensorAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(pressSensorMalfBtn, LV_STATE_CHECKED);
	}
}

/**
  * @brief	用于处理水质报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_waterAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
		lv_obj_t* target = lv_event_get_target(e);
		if (code == LV_EVENT_CLICKED)
		{
		    if (target == waterAlarmBtn)
		    {
		    	UP.AlarmType_DISensor = 0;
		    	send_aux(&UP.AlarmType_DISensor);
				lv_obj_add_state(waterAlarmBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(waterCloseBtn, LV_STATE_CHECKED);
		    }
		    else if (target == waterCloseBtn)
		    {
		    	UP.AlarmType_DISensor = 1;
		    	send_aux(&UP.AlarmType_DISensor);
				lv_obj_add_state(waterCloseBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(waterAlarmBtn, LV_STATE_CHECKED);
		    }
		}
}
/**
  * @brief	用于创建水质报警主容器
  * @param  None
  * @retval None
  */
static void tab_waterAlarm_create(void)
{
	/* 报警级别 */
	lv_obj_t* label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].AlarmLevel);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

	waterAlarmBtn = lv_btn_create(tabCont);
    lv_obj_add_style(waterAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(waterAlarmBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(waterAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 50, 0);
    lv_obj_t*lable = lv_label_create(waterAlarmBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);
    lv_obj_set_style_bg_color(waterAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, waterAlarmBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(waterAlarmBtn, tab_waterAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    waterCloseBtn = lv_btn_create(tabCont);
    lv_obj_add_style(waterCloseBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(waterCloseBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(waterCloseBtn, waterAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(waterCloseBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(waterCloseBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, waterCloseBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(waterCloseBtn, tab_waterAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 水质实测 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].waterMeasure);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(40));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 89);

	label = lv_label_create(tabCont);
	lv_label_set_text_fmt(label, "%.2f", UP.gPV_DI);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(20));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(57), 89);
	/* 报警值 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].AlarmValue);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 183);

	for (uint8_t i = 1; i <= 3; i++)
	{
		label = lv_label_create(tabCont);
		lv_label_set_text(label, "MΩ.cm");
		lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
		lv_obj_set_width(label, lv_pct(20));
		lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(77), 89 * i);
	}
    /* 控温范围 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].ctrlTemp);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(100));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 277);

	label = lv_label_create(tabCont);
	lv_label_set_text(label, "--");
	lv_obj_set_width(label, lv_pct(10));
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(49), 277);

	for(uint8_t i = 7; i < 10; i++)
	{
		textarea_create_by(tabCont, &taUser_alarm[i]);
	}
    /* 根据主板标志位判断按钮状态 */
	/* check mode btn*/
	if (UP.AlarmType_DISensor == 0)
	{
		lv_obj_add_state(waterAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(waterCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_DISensor == 1)
	{
		lv_obj_add_state(waterCloseBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(waterAlarmBtn, LV_STATE_CHECKED);
	}

}

/**
  * @brief	用于处理维护报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_remainAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
		lv_obj_t* target = lv_event_get_target(e);
		if (code == LV_EVENT_CLICKED)
		{

		    if (target == remainAlarmBtn)
		    {
		    	UP.AlarmType_Maint = 0;
		    	send_aux(&UP.AlarmType_Maint);
				lv_obj_add_state(remainAlarmBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(remainCloseBtn, LV_STATE_CHECKED);
		    }
		    else if (target == remainCloseBtn)
		    {
		    	UP.AlarmType_Maint = 1;
		    	send_aux(&UP.AlarmType_Maint);
				lv_obj_add_state(remainCloseBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(remainAlarmBtn, LV_STATE_CHECKED);
		    }
		    else if (target == pumpResetBtn)
		    {
		    	UP.rMaintFlag_Reset = 0x01;
		    	send_aux(&UP.rMaintFlag_Reset);
		    }
		    else if (target == compressResetBtn)
		    {
		    	UP.rMaintFlag_Reset = 0x02;
		    	send_aux(&UP.rMaintFlag_Reset);
		    }
		    else if (target == filterResetBtn)
		    {
		    	UP.rMaintFlag_Reset = 0x04;
		    	send_aux(&UP.rMaintFlag_Reset);
		    }
		    else if (target == compress2ResetBtn)
		    {
		    	UP.rMaintFlag_Reset = 0x08;
		    	send_aux(&UP.rMaintFlag_Reset);
		    }
		}
}
/**
  * @brief	用于创建维护报警主容器
  * @param  None
  * @retval None
  */
static void tab_remainAlarm_create(void)
{
	/* 报警级别 */
	lv_obj_t* label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].AlarmLevel);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

	remainAlarmBtn = lv_btn_create(tabCont);
    lv_obj_add_style(remainAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(remainAlarmBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(remainAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 50, 0);
    lv_obj_t*lable = lv_label_create(remainAlarmBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);
    lv_obj_set_style_bg_color(remainAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, remainAlarmBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(remainAlarmBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    remainCloseBtn = lv_btn_create(tabCont);
    lv_obj_add_style(remainCloseBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(remainCloseBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align_to(remainCloseBtn, remainAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lable = lv_label_create(remainCloseBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
    lv_obj_set_style_bg_color(remainCloseBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, remainCloseBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(remainCloseBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 循环泵 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].cyclcPump);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 94);

	label = lv_label_create(tabCont);
	lv_label_set_text_fmt(label, "%u  /  %u", UP.gRunTime_Pump, 20000);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(45), 94);

	pumpResetBtn = lv_btn_create(tabCont);
    lv_obj_add_style(pumpResetBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(pumpResetBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align(pumpResetBtn, LV_ALIGN_TOP_LEFT, lv_pct(85), 94);
    lable = lv_label_create(pumpResetBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].reset);
    lv_obj_set_style_bg_color(pumpResetBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, pumpResetBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pumpResetBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    /* 压缩机 */
	label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].compress);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 188);

	label = lv_label_create(tabCont);
	lv_label_set_text_fmt(label, "%u  /  %u", UP.gRunTime_Comp, 30000);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(45), 188);

	compressResetBtn = lv_btn_create(tabCont);
    lv_obj_add_style(compressResetBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(compressResetBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align(compressResetBtn, LV_ALIGN_TOP_LEFT, lv_pct(85), 188);
    lable = lv_label_create(compressResetBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].reset);
    lv_obj_set_style_bg_color(compressResetBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, compressResetBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(pumpResetBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	/* 过滤器 */
    label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].Filter);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 282);

	label = lv_label_create(tabCont);
	lv_label_set_text_fmt(label, "%u  /", UP.gRunTime_Filter);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(20));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(45), 282);

	filterResetBtn = lv_btn_create(tabCont);
    lv_obj_add_style(filterResetBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(filterResetBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align(filterResetBtn, LV_ALIGN_TOP_LEFT, lv_pct(85), 282);
    lable = lv_label_create(filterResetBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].reset);
    lv_obj_set_style_bg_color(filterResetBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, filterResetBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(filterResetBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	/* 压缩机2 */
    label = lv_label_create(tabCont);
	lv_label_set_text(label, dispText[DA.typeLanguage].compress2);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 376);

	label = lv_label_create(tabCont);
	lv_label_set_text_fmt(label, "%u  /  %u", UP.gRunTime_Comp2, 30000);
	lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
	lv_obj_set_width(label, lv_pct(30));
	lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(45), 376);

	compress2ResetBtn = lv_btn_create(tabCont);
    lv_obj_add_style(compress2ResetBtn, &style_btn4, LV_STATE_DEFAULT);
    lv_obj_set_style_width(compress2ResetBtn, 80, LV_STATE_DEFAULT);
    lv_obj_align(compress2ResetBtn, LV_ALIGN_TOP_LEFT, lv_pct(85), 376);
    lable = lv_label_create(compress2ResetBtn);
    lv_label_set_text(lable, dispText[DA.typeLanguage].reset);
    lv_obj_set_style_bg_color(compress2ResetBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
    lv_obj_align_to(lable, compress2ResetBtn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(compress2ResetBtn, tab_remainAlarm_event_cb, LV_EVENT_CLICKED, NULL);

    for(uint8_t i = 1; i <= 4; i++)
    {
		label = lv_label_create(tabCont);
		lv_label_set_text(label, "h");
		lv_obj_set_width(label, lv_pct(5));
		lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
		lv_obj_align(label, LV_ALIGN_TOP_LEFT, lv_pct(75), 94 * i);
    }
	textarea_create_by(tabCont, &taUser_alarm[10]);
    /* 根据主板标志位判断按钮状态 */
	/* check mode btn*/
	if (UP.AlarmType_Maint == 0)
	{
		lv_obj_add_state(remainAlarmBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(remainCloseBtn, LV_STATE_CHECKED);
	}
	else if (UP.AlarmType_Maint == 1)
	{
		lv_obj_add_state(remainCloseBtn, LV_STATE_CHECKED);
		lv_obj_clear_state(remainAlarmBtn, LV_STATE_CHECKED);
	}

}
/**
  * @brief	用于处理其他报警中的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void tab_otherAlarm_event_cb(lv_event_t* e)
{
	lv_event_code_t code = lv_event_get_code(e);
		lv_obj_t* target = lv_event_get_target(e);
		if (code == LV_EVENT_CLICKED)
		{
		    if (target == leakAlarmBtn)
		    {
		    	UP.AlarmType_OverFlow = 0;
		    	send_aux(&UP.AlarmType_OverFlow);
				lv_obj_add_state(leakAlarmBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakMalfBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakCloseBtn, LV_STATE_CHECKED);
		    }
		    else if (target == leakMalfBtn)
		    {
		    	UP.AlarmType_OverFlow = 1;
		    	send_aux(&UP.AlarmType_OverFlow);
				lv_obj_add_state(leakMalfBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakAlarmBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakCloseBtn, LV_STATE_CHECKED);
		    }
		    else if (target == leakCloseBtn)
		    {
		    	UP.AlarmType_OverFlow = 2;
		    	send_aux(&UP.AlarmType_OverFlow);
				lv_obj_add_state(leakCloseBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakMalfBtn, LV_STATE_CHECKED);
				lv_obj_clear_state(leakAlarmBtn, LV_STATE_CHECKED);
		    }
		}
}
/**
  * @brief	用于创建其他报警主容器
  * @param  None
  * @retval None
  */
static void tab_otherAlarm_create(void)
{
	    /* 检测模式 */
		lv_obj_t* label = lv_label_create(tabCont);
		lv_label_set_text(label, dispText[DA.typeLanguage].outAlarmLevel);
		lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT);
		lv_obj_set_width(label, lv_pct(45));
		lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

	    leakAlarmBtn = lv_btn_create(tabCont);
	    lv_obj_add_style(leakAlarmBtn, &style_btn4, LV_STATE_DEFAULT);
	    lv_obj_set_style_width(leakAlarmBtn, 80, LV_STATE_DEFAULT);
	    lv_obj_align_to(leakAlarmBtn, label, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
	    lv_obj_t*lable = lv_label_create(leakAlarmBtn);
	    lv_label_set_text(lable, dispText[DA.typeLanguage].alarm);
	    lv_obj_set_style_bg_color(leakAlarmBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
	    lv_obj_align_to(lable, leakAlarmBtn, LV_ALIGN_CENTER, 0, 0);
	    lv_obj_add_event_cb(leakAlarmBtn, tab_otherAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	    leakMalfBtn = lv_btn_create(tabCont);
	    lv_obj_add_style(leakMalfBtn, &style_btn4, LV_STATE_DEFAULT);
	    lv_obj_set_style_width(leakMalfBtn, 80, LV_STATE_DEFAULT);
	    lv_obj_align_to(leakMalfBtn, leakAlarmBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
	    lable = lv_label_create(leakMalfBtn);
	    lv_label_set_text(lable, dispText[DA.typeLanguage].fault);
	    lv_obj_set_style_bg_color(leakMalfBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
	    lv_obj_align_to(lable, leakMalfBtn, LV_ALIGN_CENTER, 0, 0);
	    lv_obj_add_event_cb(leakMalfBtn, tab_otherAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	    leakCloseBtn = lv_btn_create(tabCont);
	    lv_obj_add_style(leakCloseBtn, &style_btn4, LV_STATE_DEFAULT);
	    lv_obj_set_style_width(leakCloseBtn, 80, LV_STATE_DEFAULT);
	    lv_obj_align_to(leakCloseBtn, leakMalfBtn, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
	    lable = lv_label_create(leakCloseBtn);
	    lv_label_set_text(lable, dispText[DA.typeLanguage].close);
	    lv_obj_set_style_bg_color(leakCloseBtn, lv_color_hex(0x3a96f1), LV_STATE_CHECKED);
	    lv_obj_align_to(lable, leakCloseBtn, LV_ALIGN_CENTER, 0, 0);
	    lv_obj_add_event_cb(leakCloseBtn, tab_otherAlarm_event_cb, LV_EVENT_CLICKED, NULL);

	    if (UP.AlarmType_OverFlow == 0)
	    {
			lv_obj_add_state(leakAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakCloseBtn, LV_STATE_CHECKED);
	    }
	    else if (UP.AlarmType_OverFlow == 1)
	    {
			lv_obj_add_state(leakMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakAlarmBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakCloseBtn, LV_STATE_CHECKED);
	    }
	    else if (UP.AlarmType_OverFlow == 2)
	    {
			lv_obj_add_state(leakCloseBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakMalfBtn, LV_STATE_CHECKED);
			lv_obj_clear_state(leakAlarmBtn, LV_STATE_CHECKED);
	    }
}

/**
  * @brief	用于处理选项卡框架的事件回调函数
  * @param  e 触发源
  * @retval None
  */
static void event_handler(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * obj = lv_event_get_target(e);
    lv_obj_t* parent = lv_obj_get_parent(obj);
    if(code == LV_EVENT_CLICKED)
    {
    	lv_obj_del(tabCont);
    	tabCont = lv_obj_create(parentObj);
		lv_obj_set_size(tabCont, lv_pct(73), lv_pct(90));
		lv_obj_add_style(tabCont, &style_cont1, 0);
		lv_obj_set_scrollbar_mode(tabCont, LV_SCROLLBAR_MODE_OFF); // 设置滚动条模式为永不显示
		lv_obj_align(tabCont, LV_ALIGN_TOP_RIGHT, -8, 24);

		for (uint32_t i = 0; i < lv_obj_get_child_cnt(parent); i++)
		{
			lv_obj_t* child = lv_obj_get_child(parent, i);
			if (child == obj)
			{
				lv_obj_add_state(child, LV_STATE_CHECKED);
				if (child == tempAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 0;
					tab_tempAlarm_create();
				}
				else if (child == flowAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 1;
					tab_flowAlarm_create();
				}
				else if (child == pressAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 2;
					tab_pressAlarm_create();
				}
				else if (child == waterAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 3;
					tab_waterAlarm_create();
				}
				else if (child == remainAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 4;
					tab_remainAlarm_create();
				}
				else if (child == otherAlarmSideBtn)
				{
					/* 选项卡创建添加到这里 */
					alarmTabView = 5;
					tab_otherAlarm_create();
				}
			}
			else
			{
				lv_obj_clear_state(child, LV_STATE_CHECKED);
			}
		}

    }
}


/**
  * @brief	用于删除报警设置界面
  * @param  None
  * @retval None
  */
void UI_delete_alarm(void)
{
	lv_obj_del(parentObj);
	lv_obj_del(parentObj_img);  //删除当前界面
	lv_timer_del(timer_refresh_alarm);
}

/**
  * @brief	用于创建报警设置界面
  * @param  None
  * @retval None
  */
void UI_create_alarm(void)
{
	alarmTabView = 0;
	tab_alarm_init();

	parentObj_img = lv_img_create(lv_scr_act());
    lv_img_set_src(parentObj_img, &dsc_img_buff[2]);
    lv_obj_add_style(parentObj_img, &style_parentObj, LV_STATE_DEFAULT);  //添加父对象为无填充样式
    lv_obj_set_size(parentObj_img, lv_pct(100), lv_pct(100));  //设置父对象的大小
    lv_obj_align(parentObj_img, LV_ALIGN_BOTTOM_MID, 0, 0);  //设置父对象的位置

	/* 设置侧边栏按钮风格 */
	lv_style_init(&tab_btn_style);
	lv_style_set_bg_color(&tab_btn_style, lv_color_hex(0xbebdc0));
	lv_style_set_border_color(&tab_btn_style, lv_color_hex(0xbebdc0));
	lv_style_set_border_width(&tab_btn_style, 0);
	/* 设置背景风格 */
	lv_style_init(&tab_bg_style);
	lv_style_set_bg_color(&tab_bg_style, lv_color_hex(0xefefef));
    /* 界面父对象 */
//    parentObj = lv_img_create(lv_scr_act());
//    lv_img_set_src(parentObj, &img_alarm);
    parentObj = lv_obj_create(lv_scr_act());              //创建父对象
    lv_obj_add_style(parentObj, &style_parentObj, LV_STATE_DEFAULT);
    lv_obj_set_size(parentObj, lv_pct(100), lv_pct(88));  //设置父对象的大小
    lv_obj_set_style_bg_color(parentObj,lv_palette_main(LV_PALETTE_GREEN),LV_STATE_DEFAULT);
    lv_obj_align(parentObj, LV_ALIGN_BOTTOM_LEFT, 0, 0);  //设置父对象的位置
    /* 添加侧边栏容器 */
    tabList = lv_obj_create(parentObj);
	lv_obj_set_size(tabList, lv_pct(27), lv_pct(90));
	lv_obj_add_style(tabList, &style_list1, 0);
	lv_obj_set_scrollbar_mode(tabList, LV_SCROLLBAR_MODE_OFF); // 设置滚动条模式为永不显示
	lv_obj_align(tabList, LV_ALIGN_TOP_LEFT, 0, 24);
	/* 添加主容器 */
	tabCont = lv_obj_create(parentObj);
	lv_obj_set_size(tabCont, lv_pct(73), lv_pct(90));
	lv_obj_add_style(tabCont, &style_cont1, 0);
	lv_obj_set_scrollbar_mode(tabCont, LV_SCROLLBAR_MODE_OFF); // 设置滚动条模式为永不显示
	lv_obj_align(tabCont, LV_ALIGN_TOP_RIGHT, -8, 24);

	/* 添加按钮到侧边栏 */
	tempAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(tempAlarmSideBtn, 202, 89);
	lv_obj_t* label = lv_label_create(tempAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].tempAlarm);
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(tempAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(tempAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(tempAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(tempAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(tempAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);
	lv_obj_add_state(tempAlarmSideBtn, LV_STATE_CHECKED);

	flowAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(flowAlarmSideBtn, 202, 89);
	lv_obj_align_to(flowAlarmSideBtn, tempAlarmSideBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
	label = lv_label_create(flowAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].flowAlarm);
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(flowAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(flowAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(flowAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(flowAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(flowAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);

	pressAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(pressAlarmSideBtn, 202, 89);
	lv_obj_align_to(pressAlarmSideBtn, flowAlarmSideBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
	label = lv_label_create(pressAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].pressureAlarm);  //文本内容
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(pressAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(pressAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(pressAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(pressAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(pressAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);

	waterAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(waterAlarmSideBtn, 202, 89);
	lv_obj_align_to(waterAlarmSideBtn, pressAlarmSideBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
	label = lv_label_create(waterAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].waterAlarm);
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(waterAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(waterAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(waterAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(waterAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(waterAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);

	remainAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(remainAlarmSideBtn, 202, 89);
	lv_obj_align_to(remainAlarmSideBtn, waterAlarmSideBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
	label = lv_label_create(remainAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].maintenAlarm);
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(remainAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(remainAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(remainAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(remainAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(remainAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);

	otherAlarmSideBtn = lv_btn_create(tabList);
	lv_obj_set_size(otherAlarmSideBtn, 202, 89);
	lv_obj_align_to(otherAlarmSideBtn, remainAlarmSideBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
	label = lv_label_create(otherAlarmSideBtn);
    lv_label_set_text(label, dispText[DA.typeLanguage].otherAlarm);
	lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_STATE_DEFAULT);
	lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_add_style(otherAlarmSideBtn, &tab_btn_style, 0);
	lv_obj_set_style_bg_img_src(otherAlarmSideBtn, &dsc_ico_buff[2], LV_STATE_CHECKED);
	lv_obj_set_style_bg_img_src(otherAlarmSideBtn, &dsc_ico_buff[3], LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(otherAlarmSideBtn, lv_color_hex(0x9c9c9c), LV_STATE_DEFAULT);
	lv_obj_add_event_cb(otherAlarmSideBtn, event_handler, LV_EVENT_CLICKED, NULL);


	tab_tempAlarm_create();
	/* 启动定时器用于刷新数据 */
	timer_refresh_alarm = lv_timer_create(refresh_alarm_cb, 200, NULL);		// 定时刷新
}







